/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataBase;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author Anggit
 */
public class CreateTableKategoriBarang {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String jdbcUrl = "jdbc:oracle:thin:@172.23.9.185:1521:orcl";
        String userid = "mhs115314008"; // gantikan dengan username anda
        String password = "mhs115314008"; // gantikan dengan password anda

        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi is OK");
            Statement statement = conn.createStatement();

            String sql = " CREATE table KATEGORIBARANG_FROGSTONE ( KODEKATEGORI VARCHAR2(100) NOT NULL,NAMAKATEGORI VARCHAR2(20) NOT NULL, "
                    + "constraint KATEGORIII_PK primary key (KODEKATEGORI) ENABLE)";

            statement.executeUpdate(sql);
            System.out.println("Tabel KATEGORIBARANG created");
        } catch (SQLException e) {
// perform error handling here
            System.out.println("error :" + e.getMessage());
        }
    }
}
